#include "../inc/Target.hxx"
#include <cmath>
#include <iostream>

using namespace std;

Target::Target(Coordinates coordinates, Velocity velocity, double rcs) {
    this->coordinates = coordinates;
    this->velocity = velocity;
    this->rcs = rcs;
    this->height = 10;
    this->width = 50;
    this->angleWidth = 2*atan(width/coordinates.getDistance());
}

void Target::setAngleWidth(double angleWidth) {
    if(angleWidth < 0) {
        this->angleWidth = 360 + angleWidth;
    } else {
        this->angleWidth = angleWidth;
    }
}

void Target::updateCoordinates(double dTime) { //TODO fix this shit
    double x = coordinates.getX() + dTime*velocity.getDX();
    double y = coordinates.getY() + dTime*velocity.getDY();
    double z = coordinates.getZ() + dTime*velocity.getDZ();
    coordinates.setX(x);
    coordinates.setY(y);
    coordinates.setZ(z);
    angleWidth = 2*atan(width/coordinates.getDistance());  // szerokość kątowa obiektu przy założonych wymiarach
    
//    double azimuth = coordinates.getAzimuth();
//    double elevation = coordinates.getElevation();
//    double radius = coordinates.getRadius();
//    coordinates.setAzimuth(azimuth + dTime*velocity.getDAzimuth());
//    coordinates.setElevation(elevation + dTime*velocity.getDElevation());
//    coordinates.setRadius(radius + dTime*velocity.getDRadius());
}

void Target::setCoordinates(Coordinates coordinates) {
    this->coordinates = coordinates;
}

void Target::setHeight(double height) {
    this->height = height;
}

void Target::setLength(double length) {
    this->width = length;
}

void Target::setVelocity(Velocity velocity) {
    this->velocity = velocity;
}

Velocity Target::getVelocity() {
    return this->velocity;
}

Coordinates Target::getCoordinates() {
    return this->coordinates;
}

double Target::getAngleWidth() {
    return this->angleWidth;    
}

